{% extends 'layout.html' %}
{% load rbac %}

{% block content %}
    <div class="luffy-container">
        <div class="btn-group" style="margin: 5px 0">

            {% if request|has_permission:'host_add' %}
                <a class="btn btn-default" href="{% memory_url request 'host_add' %}">
                    <i class="fa fa-plus-square" aria-hidden="true"></i> 添加主机
                </a>
            {% endif %}

        </div>
        <table class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>主机名</th>
                <th>IP</th>
                <th>部门</th>
                {% if request|has_permission:'host_edit' or request|has_permission:'host_del' %}
                    <th>操作</th>
                {% endif %}

            </tr>
            </thead>
            <tbody>
            {% for row in host_queryset %}
                <tr>
                    <td>{{ row.hostname }}</td>
                    <td>{{ row.ip }}</td>
                    <td>{{ row.depart.title }}</td>
                    {% if request|has_permission:'host_edit' or request|has_permission:'host_del' %}
                        <td>
                            {% if request|has_permission:'host_edit' %}
                                <a style="color: #333333;" href="{% memory_url request 'host_edit' pk=row.id %}">
                                    <i class="fa fa-edit" aria-hidden="true"></i></a>
                            {% endif %}
                            {% if request|has_permission:'host_del' %}
                                <a style="color: #d9534f;" href="{% memory_url request 'host_del' pk=row.id %}"><i
                                        class="fa fa-trash-o"></i></a>
                            {% endif %}
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>

{% endblock %}